<?php
/**
*
*/
class InboxController extends CController
{
	public $layout = "//layouts/userpage";
	public function filters()
	{
		return CMap::mergeArray(parent::filters(),array(
			'accessControl', // perform access control for CRUD operations
		));
	}
	public function accessRules()
	{
		return array(
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('index','view','load'),
                'users'=>array('@'),
            ),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}
	public function actionIndex()
	{
		$dataProvider=new CActiveDataProvider('Inbox',array(
            'pagination'=>array(
                'pageSize'=>10,
            ),
            'criteria'=>array('condition'=> "user_id =:x",'params'=>array(':x'=>Yii::app()->user->id)),
        ));
        $this->render('index',array(
            'dataProvider'=>$dataProvider,
        ));
	}

	public function actionLoad()
	{
		$this->renderPartial('headerContent1');
	}

	public function actionView($id)
	{
		$model = Inbox::model()->findByPk($id);
		if ($model->status == 0) {
			$model->status=1;
			$model->save();
		}
		$this->render('view',array('model' => $model));
	}
}

 ?>